%{
#include <stdio.h>
#include <ctype.h>
#define YYSTYPE double
int yylex(void);
void yyerror(char const*);
%}
%token NUM
%%
input:
	| input line
;

line: '\n'
	| exp '\n' { printf("\t%lf\n",$1); }
;

exp: 	NUM	{ $$ = $1; }
	| exp exp '+' { $$ = $1 + $2; }
	| exp exp '-' { $$ = $1 - $2; }
	| exp exp '*' { $$ = $1 * $2; }
	| exp exp '/' { $$ = $1 / $2; }
;

%%
int yylex(void)
{
	int c;
	while((c = getchar()) == ' ' || c == '\t');
	if(c == '.' || isdigit(c))
	{
		ungetc(c,stdin);
		scanf("%lf",&yylval);
		return NUM;
	}
	if(c == EOF)
		return 0;
	return c;
}
int main(void)
{
	return yyparse();
}
void yyerror(char const* s)
{
	fprintf(stderr,"111%s\n",s);
}
